<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button v-if="isAuth('sys:lianorder:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button v-if="isAuth('sys:lianorder:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column prop="id" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="address" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="areaCode" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="benefittimeCo" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="benefittimeT" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="bonusCompany" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="bonusTerminal" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="cancelStaffid" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="cancelStaffname" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="cancelTag" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="cancelTime" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="identitynum" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="coopCode" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="coopName" header-align="center" align="center" label=""></el-table-column>
      <el-table-column prop="createStaffid" header-align="center" align="center" label=""></el-table-column>
      <el-table-column
        prop="createStaffname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="deductTerminal"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="deductUpstream"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="departId"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="deposit"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="deriveFrom"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="email"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="failedrizn"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="fetchedStaffid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="fetchedStaffname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="fetchedTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="finishedTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="flowid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="generatedate"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="inModeCode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="landphone"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="lianmemberid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="lianMemberid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="memberId"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="mobilephone"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="nameSn1"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="nameSn2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="nameSn3"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="nameSn4"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="onlineType"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="orderId"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="orderMonth"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="orderStatus"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="outTradeId"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="outTradeTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="pay"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="price"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="printtimes"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="productCode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="productName"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="productType"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rsrv1"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rsrv2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rsrv3"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="staffAreaCode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="statusMsg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="tradeCode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="cstmrname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="userId"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="valueSn1"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="valueSn2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="valueSn3"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="valueSn4"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="exception"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="flowstatus"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="flowstatusmsg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="terminalbonusaccount"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="createdtype"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="invoiceneed"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="outtradetime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="outtradeflowid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="wechatid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifsendmsg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msgres"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="remark"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msgphone"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="sendtimes"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifsendout"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifsendmsg2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifsendout2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msgphone2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msgres2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="msg2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifsuccess"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifconverted"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="virtualcoopname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="virtualproname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="birthday"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="cstmrrole"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="gender"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="identitytype"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcflowid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcmsg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcparams"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcstatus"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="cancellable"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="visible"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcparam1"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcparam2"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcproductcode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="belongterminalid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="belongterminalname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="wechatname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifdeductmoneysuc"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifrebackmoneysuc"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcmsgCancel"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="itfcstatusCancel"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="expireddate"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="validdays"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="ifmultiple"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="refundStaffid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="refundStaffname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="refundTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rejectreason"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rejectStaffid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rejectStaffname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="rejectTime"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="requestid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="finishedStaffid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="finishedStaffname"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="upstreamCode"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="upstreamMsg"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        prop="channelflowid"
        header-align="center"
        align="center"
        label="">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
  import AddOrUpdate from './lianorder-add-or-update'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {
      AddOrUpdate
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/sys/lianorder/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/sys/lianorder/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
